home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14518 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: syndell.demon.co.uk!derekh
  2. From: Derek E J Harper <derekh@syndell.demon.co.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: NewbieQ: How can I convert a text file (numbers) to a binary file ???
  5. Date: Sun, 31 Mar 1996 09:36:48 +0100
  6. Organization: Derek E J Harper
  7. Distribution: world
  8. Message-ID: <Q+7IiPAgQkXxEwEs@syndell.demon.co.uk>
  9. References: <4jakb6$mgi@news.acns.nwu.edu>
  10. NNTP-Posting-Host: syndell.demon.co.uk
  11. X-NNTP-Posting-Host: syndell.demon.co.uk
  12. MIME-Version: 1.0
  13. X-Newsreader: Turnpike Version 1.12 <hV17jOOVcs+gcI53Ntd6703JWh>
  14.  
  15. In article <4jakb6$mgi@news.acns.nwu.edu>, shchoi
  16. <shchoi@casbah.acns.nwu.edu> writes
  17. >
  18. >Please, help me.
  19. >
  20. >I have a text data file which is just all numbers.
  21. >How can I read this file and write to a binary file for conversion
  22. >using C ?
  23. >
  24. >I will really appreciate your help.
  25. >Thanks.
  26. >
  27. >
  28. >p.s. please e-mail me too.
  29. >
  30.  
  31. You could fscanf() the numbers of the input file
  32.  
  33. fscanf( file_ptr, "%d", &out_int );
  34.  
  35. or once they are loaded you could  atoi() them
  36.  
  37. out_int = atoi(int_str);
  38.  
  39. Cheers,
  40.   .-The--. 
  41.  /   ____| Derek E J Harper  - derekh@syndell.demon.co.uk
  42.  |  |____  'The C Side' page - http://www.geocities.com/SiliconValley/2286
  43.  \       | ::       I know the truth is out there             ::
  44.   '-Side-' ::       but I'm just too comfortable in here      ::
  45.